/**
 * Created by Administrator on 2017/9/6.
 */
;(function($){


    $.fn.myFocus = function(optins){
        var $mainObj = this;
        var defaultSetting = {
            pic:'.pic',
            points:'.nav li'
        };
        var settings = {};
        var $mainObj;
        settings = $.extend({},defaultSetting,optins)
        myFocus();
        function myFocus(){

            var index = 0;
            var bgcolor = ['#4085d2', '#fdeeeb', '#1B4046', '#D7DEE4', '#0AA9E0', '#D8DDE3', '#0C1222']
            function autoNext(){
                $lis = $mainObj.find(settings.pic).find("li");
                if (index>=$lis.length){
                    index = 0;
                }
                $lis.hide();
                $lis.eq(index).show(200);
                $mainObj.css('backgroundColor',bgcolor[index]);

                $mainObj.find(settings.points).removeClass('navnow');
                $mainObj.find(settings.points).eq(index).addClass('navnow');
                index++;

            }
            autoNext();
            var t = setInterval(autoNext,3000);
            $mainObj.find(settings.pic).find("li").hover(function(){
                clearInterval(t);
            },function(){
                t = setInterval(autoNext,3000)
            });
            $mainObj.find(settings.points).each(function(i){
                $(this).click([i],function(e){
                    index = e.data[0];
                    autoNext();
                    clearInterval(t);
                    t = setInterval(autoNext,3000);
                });
            })
        }

    }
}(jQuery));

